<style>
    .el-input__inner,
    .el-cascader {
        line-height: 30px !important;
        height: 30px !important;
    }
</style>
<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">

        <div class="rc-pannel rc-searchbox">
            <form class="layui-form " method="get">
                <div class="rc-flex-vertical-center rc-searchbox">
                    <div class="layui-inline ">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="username" placeholder="" value="<?php echo request()->get('username', ''); ?>" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline ">
                        <label class="layui-form-label">手机</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="phone" placeholder="" value="<?php echo request()->get('phone', ''); ?>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline ">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="email" placeholder="" value="<?php echo request()->get('email', ''); ?>" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline ">
                        <label class="layui-form-label">单位</label>
                        <div class="layui-input-inline ">
                            <?php echo element(
                                'organcascader',
                                name: 'organcompanyid',
                                value: request()->get('organcompanyid', 0) == '' ? '' : request()->get('organcompanyid', ''),
                                polymorphic: 1
                            ) ?>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <div class="layui-form-label">
                            <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary"><i class="iconfont">&#xeafe;</i> 搜索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>


        <div class=" rc-pannel rc-margin-top-default">



            <div class="rc-pannel-body layui-form rc-pagepadding">

                <table class="layui-table">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col style="width: 240px;">

                    </colgroup>
                    <thead>
                        <tr>
                            <th>用户名</th>
                            <th>手机</th>
                            <th>邮箱</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>单位</th>
                            <th>岗位</th>
                            <th>积分</th>
                            <th>状态</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($users as $key => $user) {
                        ?>
                            <tr>
                                <td><?php echo $user->username; ?></td>
                                <td><?php echo $user->phone; ?></td>
                                <td><?php echo $user->email; ?></td>
                                <td><?php echo $user->name; ?></td>
                                <td><?php echo $user->sex; ?></td>
                                <td><?php echo $user->organcompanyname; ?></td>
                                <td><?php echo $user->organpostname; ?></td>
                                <td><?php echo $user->integral; ?></td>
                                <td> <input autocomplete="off" value="<?php echo $user->id ?>" type="checkbox" lay-filter="EnableDisable" title="正常|禁用" <?php echo $user->status == 1 ? 'checked' : '' ?> lay-skin="switch"></td>
                                <td>
                                    <div class="rc-opbar" style="margin-left:15px">
                                        <a class="info resetPwd" href="javascript:;" uid="<?php echo $user->id ?>"> <i class="iconfont">&#xe643;</i> 重置密码</a>

                                        <a class="info moreinfomation" href="javascript:;" link="/admin/cnf/User/moreInfo?uid=<?php echo $user->id ?>"> <i class="iconfont icon-lunwenfabiaoshuliang"></i> 更多资料</a>
                                    </div>
                                </td>
                            <?php
                        }
                            ?>

                    </tbody>
                </table>
            </div>

            <div class="rc-pannel-footer">
                <div class="pagebar" id="pagebar" style="text-align: right;">
                    <?php echo paginator($users->total(), 20)
                    ?>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    layui.use(function() {

        var form = layui.form;
        var layer = layui.layer;


        $('.moreinfomation').click(function() {
            var link = $(this).attr('link');
            layer.open({
                type: 2,
                offset: 'r',
                move: false,
                anim: 'slideLeft', // 从右往左
                area: ['800px', '100%'],
                shade: 0.1,
                title: '更多信息',
                id: 'ID-demo-layer-direction-r',
                content: link
            });
        });



        form.on('switch(EnableDisable)', function(data) {
            var elem = data.elem; // 获得 checkbox 原始 DOM 对象
            var checked = elem.checked; // 获得 checkbox 选中状态
            status = -1;
            if (checked) {
                var status = 1;
            }

            $.ajax({
                url: '/admin/cnf/User/EnableDisable', //请求路径
                type: "POST", //请求方式
                data: {
                    status: status,
                    uid: elem.value
                }, // 默认写法
                success: function(data) {
                    if (data.code == 0) {
                        toastr_success("设置成功");
                    } else {
                        toastr_error(data.message);
                    }
                },
                error: function() {

                },

            });
        });

        $('.resetPwd').click(function() {
            var uid = $(this).attr('uid');
            layer.open({
                type: 2,
                offset: 'r',
                move: false,
                anim: 'slideLeft', // 从右往左
                area: ['600px', '100%'],
                shade: 0.1,
                title: '重置密码',
                id: 'ID-demo-layer-direction-r',
                content: '/admin/cnf/User/resetPwd?uid=' + uid
            });
        });

    });
</script>